package cn.ywang.concurrent.seven;

import java.util.concurrent.BlockingQueue;

/**
 * @author BeatificWang
 * @date 2019/8/1 21:33
 */
public class MessageReceiver extends Thread {

	private BlockingQueue<String> queue;

	public MessageReceiver(BlockingQueue<String> queue) {
		this.queue = queue;
	}

	@Override
	public void run() {
		while (true) {
			try {
				String message = this.queue.take();
				System.out.println("收到消息：" + message);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
